package com.example.kafka_demo.listener;

import com.example.kafka_demo.dto.ParamsDetail;
import com.example.kafka_demo.util.JsonUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @author Keson
 * @version 1.0
 * @description: TODO kafka消费者
 * @date 2021/9/6 15:23
 */
@Component
public class OrderListener {

    //用于监听kafka，符合条件的消息能够即时消费
    @KafkaListener(topics = {"${kafka.topic.kafka-demo-topic}"}, autoStartup = "${kafka.topic.autoCreate:true}")
    public void processing (String message) throws JsonProcessingException {
        ParamsDetail detail = JsonUtil.fromJson(message, ParamsDetail.class);
        System.err.println(detail);
    }

}
